/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.ds2.cafeteria.dao;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itschapala.ds2.cafeteria.modelo.Compra;
import mx.itschapala.ds2.cafeteria.modelo.Listaplatillos;

/**
 *
 * @author Santiago
 */
@Stateless
public class ListaplatillosDao extends AbstractDao<Listaplatillos> implements ListaplatillosDaoLocal {
    @PersistenceContext(unitName = "cafeteria-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ListaplatillosDao() {
        super(Listaplatillos.class);
    }
    
    @Override
    public boolean findByDuplicity(Listaplatillos platillo){
        Query q = em.createNamedQuery("Listaplatillos.findByDuplicity");
        q.setParameter("platillo", platillo.getPlatillo());
        return !q.getResultList().isEmpty();
    }

//    @Override
//    public List<Listaplatillos> findByCompra(Compra compra) {
//        Query q= em.createNamedQuery("Compra.findByBuy");
//        q.setParameter("idCompra", compra.getId());
//        return q.getResultList();
//    }
    
    
}
